package com.apes.scm.masterdata.product.model;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * @BelongsProject: apes-server
 * @BelongsPackage: com.apes.scm.masterdata.product.model
 * @ClassName: AssetClassificationCategory
 * @Author: pyb
 * @Description: 资产分类-品类
 * @CreateTime: 2021-04-22 11:36
 * @Version: 1.0
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = AssetClassifyCategory.CONST_TABLE_NAME)
public class AssetClassifyCategory extends BaseModel {
    public static final String CONST_TABLE_NAME = "mas_asset_category";
    @Id
    @Column(name = "id")
    @ApesGenerator(code = CONST_TABLE_NAME, name = "资产分类-品类")
    private String id;

    @NotNull
    @ManyToOne(optional = false)
    @JoinColumn(name = "asset_id", referencedColumnName = "id")
    private AssetClassification assetClassification;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "classify_id", referencedColumnName = "id",nullable = false)
    @Comment("商品分类编码")
    private Classify classify;
}
